package com.ekin.attendance.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ekin.attendance.model.entity.Leave;
import com.ekin.attendance.model.query.LeavePageQuery;
import com.ekin.attendance.model.vo.LeavePageVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * 请假Mapper
 * @author Ekin
 * @date 2021/12/08
 */
@Mapper
public interface LeaveMapper extends BaseMapper<Leave> {
    /**
     * 请假分页列表
     *
     * @param page 分页参数
     * @param queryParams 查询参数
     * @return 请假分页列表
     */
    Page<LeavePageVO> getLeavePage(Page<LeavePageVO> page, LeavePageQuery queryParams);

    /**
     * 获取最大申请单号
     *
     * @param fullPrefix 申请单号前缀
     * @return 最大申请单号
     */
    @Select("SELECT MAX(applyer_number) FROM att_leave WHERE applyer_number LIKE CONCAT(#{prefix}, '%')")
    String getMaxApplyNoByPrefix(String prefix);

}
